//获取应用实例
var util = require('../../utils/util.js')
const app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    xinz: {
      errMsg: 'request:ok',
      data: {
        zhanlve_list: [
          {
            detail: "2060年实现碳中和",
            id: "76",
            is_show: "1",
            order_id: "100",
            picture: "a:0:{}",
            seo_meta: null,
            title: "围绕1个远景目标",
            title2: null,
            video_url: null,
          },
          {
            detail: "能源互联网↵数字经济",
            id: "77",
            is_show: "1",
            order_id: "100",
            picture: "a:0:{}",
            seo_meta: null,
            title: "立足2大核心产业",
            title2: null,
            video_url: null,
          },
          {
            detail: "资金、技术、人才",
            id: "78",
            is_show: "1",
            order_id: "100",
            picture: "a:0:{}",
            seo_meta: null,
            title: "提供3大核心保障",
            title2: null,
            video_url: null,
          },
          {
            detail: "知书达礼↵知难而进↵知恩图报↵知行合一",
            id: "79",
            is_show: "1",
            order_id: "100",
            picture: "a:0:{}",
            seo_meta: null,
            title: "培养4知人才",
            title2: null,
            video_url: null,
          },
          {
            detail: "数字化创新发展↵数字化协调发展↵数字化绿色发展↵数字化开放发展↵数字化共享发展",
            id: "80",
            is_show: "1",
            order_id: "100",
            picture: "a:0:{}",
            seo_meta: null,
            title: "秉承5大发展理念",
            title2: null,
            video_url: null,
          },
          {
            detail: "建设数字政府↵创建数字园区↵共建数字生态↵设立数字基金↵孵化数字企业↵数字赋能产业",
            id: "81",
            is_show: "1",
            order_id: "100",
            picture: "a:0:{}",
            seo_meta: null,
            title: "打造6个1数字工程",
            title2: "",
            video_url: null,
          }
        ],
        data:
        {
          create_time: "0",
          detail: "郑州荥泽数链产业发展有限公司围绕2060年实现碳中和为远景目标，立足能源互联网和数字经济两大核心产业，以技术、资金、人才为核心保障，运用“IABCDGN”（物联网、人工智能、区块链、大数据、云计算、5G、虚拟现实、数字孪生）等数字化技术，赋能产业数字化、数字产业化、数据价值化和数字化治理等多个领域，助力数字社会和低碳社会的建设和发展。",
          detail2: "a:0:{}",
          detail3: "中银（南昌）分所拥有执业律师及行政人员160人，各合伙人分别专精于特定的专业领域，通过合理的专业分工和紧密的团队合作，中银（南昌）分↵所有能力在各个领域为客户提供高质量的法律服务。尤其是在新型及热点领域，如新三板、私募股权基金投资。",
          detail4: "超前布局、力争主动，推动了分所的跨越式发展，成为江西综合实力排名靠前的大型综合性律师事务所。",
          id: "1",
          p1: "业务领域",
          p2: "全球机构",
          p3: "新闻资讯",
          p4: "http://www.baidu.com",
          p5: "advantages",
          p6: "企业发展历程",
          p7: "Development",
          p8: "荣誉资质",
          p9: "Honor",
          picture: "https://yingze.fwwl.net/Uploads/Temp/image/20220623/62b3d076ab161.jpg",
          picture2: "https://yingze.fwwl.net/Uploads/Temp/image/20220627/62b914bd6ea43.jpg",
          picture3: "https://yingze.fwwl.net/Uploads/Temp/image/20220623/62b3d3453544b.png",
          picture4: "a:0:{}",
          picture5: "a:0:{}",
          picture6: "a:0:{}",
          seo_meta: 'a:3:{s:9:"seo_title";s:12:"公司简介";s:12:"seo_keywords";s:12:"公司简介";s:15:"seo_description";s:12:"公司简介";}',
          site_url: null,
          title: "关于我们",
          title2: "成为国内领先数字化方案提供商和能源互联网企业发展服务商",
          type: "1",
          url: "https://mp.weixin.qq.com/s/TqA-KT1KrTXLJ5OyRhf27w",
          v1: "",
          v2: "",
          v3: "",
          v4: "",
          v5: "",
          v6: null,
          v7: null,
          v8: null,
          v9: null,
          video_url: "https://xin20181116.oss-cn-beijing.aliyuncs.com/yingze/yingze.mp4",
        }
      }
    },
    lastX: 0,     //滑动开始x轴位置
    lastY: 0,     //滑动开始y轴位置
    text: "没有滑动",
    currentGesture: 0, //标识手势
    curNav: 0, //当前导航
    isVideo: false,
    model: [],
    zhanlve_list: []
  },

  //滑动移动事件
  handletouchmove: function (event) {
    var currentX = event.touches[0].pageX
    var currentY = event.touches[0].pageY
    var tx = currentX - this.data.lastX
    var ty = currentY - this.data.lastY
    var text = ""
    //左右方向滑动
    if (Math.abs(tx) > Math.abs(ty)) {
      if (tx < 0)
        text = "向左滑动"
      else if (tx > 0)
        text = "向右滑动"
    }
    //上下方向滑动
    else {
      if (ty < 0)
        text = "向上滑动"
      else if (ty > 0)
        text = "向下滑动"
    }


    //将当前坐标进行保存以进行下一次计算
    this.data.lastX = currentX
    this.data.lastY = currentY
    this.setData({
      text: text,
    });
  },

  //滑动开始事件
  handletouchtart: function (event) {
    this.data.lastX = event.touches[0].pageX
    this.data.lastY = event.touches[0].pageY
  },
  //滑动结束事件
  handletouchend: function (event) {
    this.data.currentGesture = 0;
    var lastX = this.data.lastX
    console.log('x:' + lastX)
    if (lastX > 50) {
      // util.move_skip('pingtai')
    }
    this.setData({
      lastX: 0,
    });
  },
  loadFontFace: function () {
    wx.loadFontFace({
      family: 'xiaokai',
      source: 'url("https://xin20181116.oss-cn-beijing.aliyuncs.com/yingze/xiaokai.ttf")',
      fail: console.log
    })
  },
  playVideo: function () {
    var _that = this;
    _that.setData({
      isVideo: !_that.data.isVideo
    })
  },
  videoPause: function () {
    var _that = this;
    _that.setData({
      isVideo: !_that.data.isVideo
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // console.log(app);

    var that = this
    // that.loadFontFace();
    load_index(that)
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    this.videoContext = wx.createVideoContext('myVideo');
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})


function load_index(that) {

  var xinz = {
    errMsg: 'request:ok',
    data: {
      zhanlve_list: [
        {
          detail: "2060年实现碳中和",
          id: "76",
          is_show: "1",
          order_id: "100",
          picture: "a:0:{}",
          seo_meta: null,
          title: "围绕1个远景目标",
          title2: null,
          video_url: null,
        },
        {
          detail: "能源互联网↵数字经济",
          id: "77",
          is_show: "1",
          order_id: "100",
          picture: "a:0:{}",
          seo_meta: null,
          title: "立足2大核心产业",
          title2: null,
          video_url: null,
        },
        {
          detail: "资金、技术、人才",
          id: "78",
          is_show: "1",
          order_id: "100",
          picture: "a:0:{}",
          seo_meta: null,
          title: "提供3大核心保障",
          title2: null,
          video_url: null,
        },
        {
          detail: "知书达礼↵知难而进↵知恩图报↵知行合一",
          id: "79",
          is_show: "1",
          order_id: "100",
          picture: "a:0:{}",
          seo_meta: null,
          title: "培养4知人才",
          title2: null,
          video_url: null,
        },
        {
          detail: "数字化创新发展↵数字化协调发展↵数字化绿色发展↵数字化开放发展↵数字化共享发展",
          id: "80",
          is_show: "1",
          order_id: "100",
          picture: "a:0:{}",
          seo_meta: null,
          title: "秉承5大发展理念",
          title2: null,
          video_url: null,
        },
        {
          detail: "建设数字政府↵创建数字园区↵共建数字生态↵设立数字基金↵孵化数字企业↵数字赋能产业",
          id: "81",
          is_show: "1",
          order_id: "100",
          picture: "a:0:{}",
          seo_meta: null,
          title: "打造6个1数字工程",
          title2: "",
          video_url: null,
        }
      ],
      data:
      {
        create_time: "0",
        detail: "郑州荥泽数链产业发展有限公司围绕2060年实现碳中和为远景目标，立足能源互联网和数字经济两大核心产业，以技术、资金、人才为核心保障，运用“IABCDGN”（物联网、人工智能、区块链、大数据、云计算、5G、虚拟现实、数字孪生）等数字化技术，赋能产业数字化、数字产业化、数据价值化和数字化治理等多个领域，助力数字社会和低碳社会的建设和发展。",
        detail2: "a:0:{}",
        detail3: "中银（南昌）分所拥有执业律师及行政人员160人，各合伙人分别专精于特定的专业领域，通过合理的专业分工和紧密的团队合作，中银（南昌）分↵所有能力在各个领域为客户提供高质量的法律服务。尤其是在新型及热点领域，如新三板、私募股权基金投资。",
        detail4: "超前布局、力争主动，推动了分所的跨越式发展，成为江西综合实力排名靠前的大型综合性律师事务所。",
        id: "1",
        p1: "业务领域",
        p2: "全球机构",
        p3: "新闻资讯",
        p4: "http://www.baidu.com",
        p5: "advantages",
        p6: "企业发展历程",
        p7: "Development",
        p8: "荣誉资质",
        p9: "Honor",
        picture: "https://yingze.fwwl.net/Uploads/Temp/image/20220623/62b3d076ab161.jpg",
        picture2: "https://yingze.fwwl.net/Uploads/Temp/image/20220627/62b914bd6ea43.jpg",
        picture3: "https://yingze.fwwl.net/Uploads/Temp/image/20220623/62b3d3453544b.png",
        picture4: "a:0:{}",
        picture5: "a:0:{}",
        picture6: "a:0:{}",
        seo_meta: 'a:3:{s:9:"seo_title";s:12:"公司简介";s:12:"seo_keywords";s:12:"公司简介";s:15:"seo_description";s:12:"公司简介";}',
        site_url: null,
        title: "关于我们",
        title2: "成为国内领先数字化方案提供商和能源互联网企业发展服务商",
        type: "1",
        url: "https://mp.weixin.qq.com/s/TqA-KT1KrTXLJ5OyRhf27w",
        v1: "",
        v2: "",
        v3: "",
        v4: "",
        v5: "",
        v6: null,
        v7: null,
        v8: null,
        v9: null,
        video_url: "https://xin20181116.oss-cn-beijing.aliyuncs.com/yingze/yingze.mp4",
      }
    }
  }
  console.log(xinz);
  that.setData({
    model: xinz.data.data,
    zhanlve_list: xinz.data.zhanlve_list
  })
  util.showToast(xinz.errMsg)

  // var request_banner_url = util.getApiUrl(app, "/About/index", "")
  // util._get(request_banner_url,
  //   function (res) {
  //     var model = res.data.data
  //     that.setData({
  //       model: model,
  //       zhanlve_list: res.data.zhanlve_list
  //     })
  //     wx.setNavigationBarTitle({
  //       title: model.title
  //     })
  //     console.log(res.data.data.title,1111111111);
  //   },
  
  //   function (res) {
  //     util.showToast(res.errMsg)
  //   }
  // )
}